<template>
  <div class="recommendContainer">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>预算推荐工程</span>
      </div>
      <el-table
        :cell-style="{textAlign:'center'}"
        :data="recommendData"
        :header-cell-style="{textAlign:'center'}"
        style="width: 100%"
      >
        <el-table-column
          label="预算ID"
          prop="budgetId"
        />
        <el-table-column
          label="文章ID"
          prop="articleId"
        />
        <el-table-column
          label="文章标题"
          prop="articleTitle"
        />
        <el-table-column
        label="操作">
          <template slot-scope="scope">
            <el-button type="danger" size="mini" @click="deleteItem(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        style="margin: 20px 0;float: right"
        v-show="queryParams.total>0"
        :total="queryParams.total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getData"
      />
    </el-card>
  </div>
</template>

<script>
import { delRecommendProjectList, getRecommendList } from '@/api/recommendProject'

export default {
  name: "recommendProject",
  data(){
    return{
      //分页查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        total:0
      },
      recommendData:[]
    }
  },
  created() {
    this.getData()
  },
  methods:{
    //获取分页数据
    getData(){
      getRecommendList().then(res=>{
        this.recommendData=res.data.records
        this.queryParams.total=res.data.total
      })
    },
    deleteItem(row){
      this.$confirm('是否删除',{
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(res=>{
        delRecommendProjectList(row.id).then(res=>{
          this.getData()
          this.$message.success('删除成功')
        })
      }).then(()=>{
      })
    }
  }
}
</script>

<style scoped lang="scss">
.recommendContainer{
  padding: 20px;
}
</style>
